package com.common.filter;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class EncodingFilter extends FilterAdapter {

	protected String EncodingType = "";

	@Override
	public void init(FilterConfig config) throws ServletException {
		EncodingType = config.getInitParameter("Encoding");
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		if (EncodingType != null) {
			request.setCharacterEncoding(EncodingType);
		}
		chain.doFilter(request, response);
	}
}
